<?php

$app->group('/json', function () use ($app){
   $app->get('/events', function() use ($app){
       echo json_encode(Events::all(), JSON_PRETTY_PRINT);
   });
   $app->get('/event/:id', function($id) use ($app){
       echo json_encode(Events::find($id), JSON_PRETTY_PRINT);
   });
   $app->get('/venues', function() use ($app){
       echo json_encode(Venues::all(), JSON_PRETTY_PRINT);
   });
   $app->get('/venue/:id', function($id) use ($app){
       echo json_encode(Venues::find($id), JSON_PRETTY_PRINT);
   });
   $app->get('/foods', function() use ($app){
       echo json_encode(FoodPlaces::all(), JSON_PRETTY_PRINT);
   });
   $app->get('/food/:id', function($id) use ($app){
       echo json_encode(FoodPlaces::find($id), JSON_PRETTY_PRINT);
   });
   $app->get('/races', function() use ($app){
       echo json_encode(Events::where('event_category', '!=', 'Entertainment')->get(), JSON_PRETTY_PRINT);
   });
   $app->get('/races/:sport', function($sport) use ($app){
       echo json_encode(Events::where('event_category', '=', $sport)->get(), JSON_PRETTY_PRINT);
   });
});